package com.longge;

public class DiStringMatch {
    public int[] diStringMatch(String s) {

        char[] chars = s.toCharArray();
        int[] res = new int[s.length() + 1];
        int left = 0, right = s.length();
        for (int i = 0; i < chars.length; i++) {
            char aChar = chars[i];
            if (aChar == 'I') {
                res[i] = left++;
            } else {
                res[i] = right--;
            }
        }
        res[chars.length] = left;
        return res;
    }
}
